<template>
    <framework title="联系我们" :bg="require('@/assets/img/search_result.png')"
               :content-bg="require('@/assets/img/business-list-img-one.png')" :wrap-style="{padding:0}"
               :path="[{name:'联系我们',path:'/contactUs'}]">
        <div class="contact-us">
            <div class="box">
                <div class="box_header">
                    <div>请您留言</div>
                </div>
                <div class="box_bottom">
                    <div class="form">
                        <div class="input-item">
                            <div class="input-textarea-box">
                                <textarea v-model="formInfo.content" placeholder="请在此输入留言内容，我们会尽快与您联系。（必填）"/>
                            </div>
                        </div>
                        <div class="input-item">
                            <i class="icon_name">
                                <img src="~@/assets/img/contact-name.png" alt="">
                            </i>
                            <div>姓名:</div>
                            <input v-model="formInfo.username" type="text" placeholder="">
                        </div>
                        <div class="input-item">
                            <i class="icon_name">
                                <img src="~@/assets/img/concat-phone.png" alt="">
                            </i>
                            <div>电话:</div>
                            <input v-model="formInfo.phone" type="text" >
                        </div>
                        <div class="input-item">
                            <i class="icon_name">
                                <img src="~@/assets/img/concat-email.png" alt="">
                            </i>
                            <div>邮箱:</div>
                            <input v-model="formInfo.email" type="text" placeholder="">
                        </div>
                        <div class="input-item">
                            <i class="icon_name">
                                <img src="~@/assets/img/concat-location.png" alt="">
                            </i>
                            <div>地址:</div>
                            <input v-model="formInfo.address" type="text" placeholder="">
                        </div>

                    </div>
                    <div class="button">
                        <div class="base-button" @click="saveInfo">{{$t('index.contact.button')}}</div>
                    </div>
                </div>
            </div>
        </div>

    </framework>
</template>

<script>

import framework from '@/components/frameworks'
//联系我们
export default {
    name: "ContactUs",
    components: {framework},
    data() {
        return {
            formInfo: {
                content: '',
                username: '',
                phone: '',
                email: '',
                address: '',
            }
        }
    },
    methods: {
        async saveInfo() {

            try {
                await this.$http.post("/concatus/save", JSON.stringify(this.formInfo), {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                })
                this.$toast.success("发送成功");
                Object.keys(this.formInfo).forEach(key => this.formInfo[key] = '');
            } catch (e) {
                console.log(e)
                this.$toast.fail(e.msg.replaceAll('<br>', '\n'))
            }

        }
    },

}
</script>

<style scoped lang="less">

.sq_part_bottom {
    display: flex;
    justify-content: center;
    align-items: center;
}

.contact-us {
    background: rgba(255, 255, 255, 0.6);
    padding: 100px 0;

    .box {
        display: flex;
        align-items: center;
        flex-direction: column;

        .box_header {
            text-align: center;
            background: #855949;
            padding: 25px 25px;
            color: #FFFFFF;
            letter-spacing: 5px;
            width: 30%;
            font-weight: 600;
        }

        .box_bottom {
            width: 30%;
            background: rgba(255, 255, 255, 0.8);
            padding: 25px 25px;
            display: flex;
            flex-direction: column;
            align-items: center;

            .form {
                width: 100%;

                .input-textarea-box {
                    width: calc(100% - 40px);
                    padding: 20px 20px 10px 20px;
                    border: 1px solid #BCBBBA;
                }

                .input-item:first-child {
                    border: none;
                }

                .input-item {
                    width: 100%;
                    margin: 20px 0;
                    border-bottom: 1px solid #BCBBBA;
                    display: flex;
                    justify-content: center;
                    align-items: center;

                    i {
                        margin: 0 20px 0 0;

                        img {
                            width: 20px;
                        }
                    }

                    input {
                        width: calc(100% - 100px);
                        height: 50px;
                        border: none;
                        background: none;
                    }

                    textarea {
                        width: 100%;
                        height: 200px;
                        border: none;
                        background: none;
                    }
                }
            }

            .button {
                margin: 20px 0;
                cursor: pointer;
                div {
                    padding: 10px 100px;
                }
            }
        }


    }
}


</style>


<style lang="less">
@media screen and (min-width:0px) and (max-width:680px) {
  #app {
    .contact-us {
      .box {
        .box_header{
          width: 80%;
        }
        .box_bottom{
          width: 80%;
          .form{
            .input-item {
              i{
                img{
                  width: 15px;
                }
              }
              textarea{
                height: 100px;
              }
              input{
                height: 30px;
              }
            }
          }
        }
      }
    }
  }
}
</style>
